<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:tx="http://www.springframework.org/schema/tx"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.1.xsd
				         	http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.1.xsd">

    <description>MyBatis配置</description>
	<bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource" init-method="init" destroy-method="close">
	    <property name="driverClassName" value="${r"${druid.driverClassName}"}"/>
		<property name="url" value="${r"${druid.url}"}"/>
		<property name="username" value="${r"${druid.username}"}"/>
		<property name="password" value="${r"${druid.password}"}"/>
		<property name="connectionProperties" value="${r"${druid.connectionProperties}"}"/>             
		<property name="initialSize" value="${r"${druid.initialSize}"}"/>
		<property name="minIdle" value="${r"${druid.minIdle}"}"/>
		<property name="maxActive" value="${r"${druid.maxActive}"}"/>
		<property name="maxWait" value="${r"${druid.maxWait}"}"/>
		<property name="validationQuery" value="${r"${druid.validationQuery}"}"/>
		<property name="testWhileIdle" value="${r"${druid.testWhileIdle}"}"/>
		<property name="testOnBorrow" value="${r"${druid.testOnBorrow}"}"/>
		<property name="testOnReturn" value="${r"${druid.testOnReturn}"}"/>
		<property name="timeBetweenEvictionRunsMillis" value="${r"${druid.timeBetweenEvictionRunsMillis}"}"/>
		<property name="minEvictableIdleTimeMillis" value="${r"${druid.minEvictableIdleTimeMillis}"}"/>
		<property name="poolPreparedStatements" value="${r"${druid.poolPreparedStatements}"}"/>
		<property name="maxPoolPreparedStatementPerConnectionSize" value="${r"${druid.maxPoolPreparedStatementPerConnectionSize}"}"/>
        <property name="useGlobalDataSourceStat" value="true"/><!-- 合并统计多个数据源 -->
	</bean>

    <!-- (事务管理)transaction manager -->
    <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
        <property name="dataSource" ref="dataSource" />
    </bean>

    <!-- 声明式事务 -->
    <tx:annotation-driven transaction-manager="transactionManager" proxy-target-class="true" />

    <!-- 配置sqlSessionFactory -->
    <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
        <property name="dataSource" ref="dataSource" />
        <property name="configLocation" value="classpath:/mybatis/SqlMapConfig.xml" />
    </bean>

    <!-- mybatis mapping包扫描  配置扫描DAO-->
    <bean id="daoScan"  class="org.mybatis.spring.mapper.MapperScannerConfigurer">
        <property name="basePackage" value="com.smart.dao.**" />
        <property name="sqlSessionFactoryBeanName" value="sqlSessionFactory" />
    </bean>

    <!-- 配置SqlSessionTemplate 用于深入控制、批量操作 -->
    <bean id="mySqlSessionTemplate" class="org.mybatis.spring.SqlSessionTemplate">
        <constructor-arg name="sqlSessionFactory" ref="sqlSessionFactory" />
    </bean>

</beans>